package huixue.cn.com.rxapp.stock.util;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
import android.graphics.RectF;

/**
 * Created by Administrator on 2018/8/19.
 */

public class GridUtils {

    /**
     * 画网格
     */
    public static void drawGrid(Canvas canvas, RectF candleRect) {

        Paint mGridPaint = new Paint();
        mGridPaint.setStyle(Paint.Style.STROKE);
        mGridPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        mGridPaint.setStyle(Paint.Style.STROKE);
        mGridPaint.setStrokeWidth(1);
        mGridPaint.setColor(Color.GRAY);

        canvas.drawRect(candleRect, mGridPaint);
        canvas.drawLine(candleRect.left, candleRect.height() / 2 + candleRect.top, candleRect.right, candleRect.height() / 2 + candleRect.top, mGridPaint);
        canvas.drawLine(candleRect.centerX(),  candleRect.top,candleRect.centerX(), candleRect.bottom, mGridPaint);

        mGridPaint.setPathEffect(new DashPathEffect(
                new float[]{8, 8, 8, 8}, 1));

        canvas.drawLine(candleRect.left, candleRect.height() / 4 + candleRect.top, candleRect.right, candleRect.height() / 4 + candleRect.top, mGridPaint);
        canvas.drawLine(candleRect.left, candleRect.height() / 4*3 + candleRect.top, candleRect.right, candleRect.height() / 4*3 + candleRect.top, mGridPaint);

        canvas.drawLine(candleRect.left+candleRect.width()/4,  candleRect.top,candleRect.left+candleRect.width()/4, candleRect.bottom, mGridPaint);

        canvas.drawLine(candleRect.left+candleRect.width()/4*3,  candleRect.top,candleRect.left+candleRect.width()/4*3,candleRect.bottom, mGridPaint);
    }
}
